package com.situ.web.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class JSONUtil {

	/**
	 * 将任意对象转换为json返回给浏览器 {} []
	 * to 
	 * @param obj
	 */
	public static void obj2Json(Object obj, HttpServletResponse response) throws IOException {
		response.setContentType("text/html;charset=utf-8");
		ObjectMapper objectMapper = new ObjectMapper();
		objectMapper.writeValue(response.getWriter(), obj);
	}
}
